import collections
class Solution(object):
    def wordCount(self, startWords, targetWords):
        wait = set()
        for w in startWords:
            c = collections.Counter(w)
            numbers = [0] * 26
            for i in range(26):
                numbers[i] = c[chr(i + ord('a'))]
            wait.add(tuple(numbers))
        ans = 0
        for w in targetWords:
            c = collections.Counter(w)
            numbers = [0] * 26
            for i in range(26):
                numbers[i] = c[chr(i + ord('a'))]
            for i in range(26):
                if numbers[i] == 1:
                    numbers[i] = 0
                    if tuple(numbers) in wait:
                        ans += 1
                        break
                    numbers[i] = 1
        return ans
